Refactor MSL authentication checks#606
Open
MattyTheHacker wants to merge 92 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
This pull request has a merge conflict with the base branch! Please resolve the conflict manually, remove the conflict label and re-add the filter label (if applicable). |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (2)
utils/msl/core.py:52
self.cookiesis typed/used as a mapping (passed toaiohttp.ClientSession(..., cookies=...)and indexed with[".AspNet.SharedCookie"]), but it’s initialised fromsettings["SU_PLATFORM_ACCESS_COOKIE"], which is configured as a raw string inconfig.py. This will break request construction and cookie refresh logic; initialiseself.cookiesas{'.AspNet.SharedCookie': settings['SU_PLATFORM_ACCESS_COOKIE']}(or change the settings value to be a mapping consistently).
self.headers: Mapping[str, str] = settings["SU_PLATFORM_WEB_HEADERS"]
self.cookies: Mapping[str, str] = settings["SU_PLATFORM_ACCESS_COOKIE"]
async def fetch_url_content(self, url: str) -> str:
async with (
aiohttp.ClientSession(headers=self.headers, cookies=self.cookies) as http_session,
http_session.get(url=url, ssl=GLOBAL_SSL_CONTEXT) as http_response,
):
returned_asp_cookie: Morsel[str] | None = http_response.cookies.get(
".AspNet.SharedCookie"
)
if not returned_asp_cookie:
return await http_response.text()
if returned_asp_cookie.value != self.cookies[".AspNet.SharedCookie"]:
logger.info("New SU platform access cookie given by server; updating local.")
self.cookies = {
".AspNet.SharedCookie": returned_asp_cookie.value,
}
cogs/check_su_platform_authorisation.py:80
- The f-string used to format the organisation list is syntactically invalid (
f"\n{followed by a newline). This will raise aSyntaxErrorand prevent the cog from importing; build the joined string in a variable (or keep the{...}expression on a single line) before interpolating it.
await ctx.followup.send(
content=(
"No MSL organisations are available to the SU platform access cookie. "
"Please check the logs for errors."
if not su_platform_access_cookie_organisations
else (
f"SU Platform Access Cookie has access to the following "
"MSL Organisations:"
f"\n{
',\n'.join(
organisation
for organisation in su_platform_access_cookie_organisations
)
}"
)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
depends on #605